package com.example.springbootdemo.异步注解失效测试.controller;

import com.example.springbootdemo.异步注解失效测试.service.PrintOne;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("async")
public class AsyncController {
    /**
     * 异步方法执行成功
     */
    @Autowired
    PrintOne printOne;

    @RequestMapping(method = RequestMethod.GET,value = "one")
    public String test2() {
        printOne.java();
        System.out.println("主线程名"+ Thread.currentThread().getName());
        return "方法返回值";
    }

    @RequestMapping(method = RequestMethod.GET,value = "two")
    public String test1() {
        printOne.python();

        System.out.println("主线程名"+ Thread.currentThread().getName());
        return "方法返回值";
    }

    @RequestMapping(method = RequestMethod.GET,value = "three")
    public String test3() {
        PrintOne printOne1 = new PrintOne();
        printOne.python();
        System.out.println("主线程名"+ Thread.currentThread().getName());
        return "方法返回值";
    }
}
